#ifndef _LOGIC_H_
#define _LOGIC_H_

struct connection;

struct stlogic {
	void (*on_read)(struct connection * conn, void * ctx);
	void (*on_accept)(struct connection * conn, void * ctx);
	void (*on_closed)(struct connection * conn, int reason, void * ctx);
	void * ctx;
};

extern struct stlogic * logic;

#define DELCLARE_LOGIC(read_func, accept_func, closed_func, p) \
	struct stlogic logic_ = { \
		.on_read = (read_func), \
		.on_accept = (accept_func), \
		.on_closed = (closed_func), \
		.ctx = (p)\
	}; \
	struct stlogic * logic =  &logic_; 

#endif
